package org.xpandaframework.base.service.impl;

import org.xpandaframework.base.curd.BaseDao;
import org.xpandaframework.base.curd.impl.BaseEntity;
import org.xpandaframework.base.exception.XpandaFrameworkException;
import org.xpandaframework.base.service.BaseService;

/**
 * <p>
 * CopyRright (c)2008-2014: Camelot
 * <p>
 * Project: xpandaframework
 * <p>
 * Module ID: <模块类编号可以引用系统设计中的类编号>
 * <p>
 * Comments: 基础服务实现
 * <p>
 * JDK version used: JDK1.7
 * <p>
 * NameSpace: org.xpandaframework.base.service.impl.BaseServiceImpl.java
 * <p>
 * Author: Angus
 * <p>
 * Create Date: 2014年11月25日
 * <p>
 * Modified By: <修改人中文名或拼音缩写>
 * <p>
 * Modified Date: <修改日期>
 * <p>
 * Why & What is modified: <修改原因描述>
 * <p>
 * Version: v1.0
 */
public abstract class BaseServiceImpl<T extends BaseEntity> implements BaseService<T> {

  /**
   * 获得基础持久层
   *
   * @return BaseDao<T>
   */
  protected abstract BaseDao<T> getBaseDao();

  /*
   * (非 JavaDoc)
   * <p>Title: create</p>
   * <p>Description: </p>
   * @param t
   * @return
   * @throws BaseServiceException
   * @see org.xpandaframework.base.service.BaseService#create(org.xpandaframework.base.curd.impl.BaseEntity)
   */
  @Override
  public T create(T t) throws XpandaFrameworkException {
    return getBaseDao().create(t);
  }

  /*
   * (非 JavaDoc)
   * <p>Title: sqlUpdateById</p>
   * <p>Description: </p>
   * @param t
   * @return
   * @throws XpandaFrameworkException
   * @see org.xpandaframework.base.service.BaseService#sqlUpdateById(org.xpandaframework.base.curd.impl.BaseEntity)
   */
  @Override
  public int updateById(T t) throws XpandaFrameworkException {
    return getBaseDao().updateById(t);
  }

  /*
   * (非 JavaDoc)
   * <p>Title: readOneById</p>
   * <p>Description: </p>
   * @param id
   * @return
   * @throws XpandaFrameworkException
   * @see org.xpandaframework.base.service.BaseService#readOneById(java.lang.String)
   */
  @Override
  public T readOneById(String id) throws XpandaFrameworkException {
    return getBaseDao().readOneById(id);
  }

  /*
   * (非 JavaDoc)
   * <p>Title: delOneById</p>
   * <p>Description: </p>
   * @param id
   * @return
   * @throws XpandaFrameworkException
   * @see org.xpandaframework.base.service.BaseService#delOneById(java.lang.String)
   */
  @Override
  public int delOneById(String id) throws XpandaFrameworkException {
    return getBaseDao().delOneById(id);
  }
}
